package lesson02_udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class UdpClientDemo01 {
    public static void main(String[] args) throws Exception {
         //1.创建一个Socket
        DatagramSocket socket=new DatagramSocket();

         //2.建个包
          String msg="你好 ，服务器";
        InetAddress localhost=InetAddress.getByName("localhost");
        int port =99;

        //数据，数据的长度，要发送给睡
        DatagramPacket packet=new DatagramPacket(msg.getBytes(),0,msg.length(),localhost,port);

         //3。发送包
        socket.send(packet);

         //4.关闭源
        socket.close();
    }
}
